var basicCount = 0,recCount=0,jobCount=0,nowJobCount=0;
$(function(){
	
	//求职人数
	queryBasicPersonCount();
	//招聘人数
	queryRecPersonCount();
	//岗位数
	queryJobCount();
	//每日岗位数
	queryNowJobCount();
	
	
});

function queryBasicPersonCount(){
	utilAjax("/basic_information/queryBasicPersonCount","","get",
			function(data){
		basicCount = data;
		echartsInit();
	});
}
function queryRecPersonCount(){
	utilAjax("/recruiter/queryRecPersonCount","","get",
			function(data){
		recCount = data;
		echartsInit();
	});
}
function queryJobCount(){
	utilAjax("/recruitment_msg/queryJobCount","","get",
			function(data){
		jobCount = data;
		echartsInit();
	});
}
function queryNowJobCount(){
	utilAjax("/recruitment_msg/queryNowJobCount","","get",
			function(data){
		nowJobCount = data;
		echartsInit();
	});
}

function echartsInit(){
	// 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'));

    // 指定图表的配置项和数据
    var option = {
        title: {
            text: '系统统计'
        },
        tooltip: {},
        legend: {
            data:['本站统计']
        },
        xAxis: {
            data: ["求职人数","招聘人数","岗位数总","日招聘岗位数"]
        },
        yAxis: {},
        series: [{
            name: '本站统计',
            type: 'bar',
            data: [basicCount, recCount, jobCount, nowJobCount]
        }]
    };

    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
}

function utilAjax(url,data,type,success){
	$.ajax({
		url:url,
		data:data,
		dataType:'json',
		type:type,
		success:success,
		error:function(){
		}
	});
}